<!doctype html>
<html lang="zh">
<head>
    <meta charset="utf-8">
    <title>设置中心</title>
    <meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=0">
    <link rel="stylesheet" href="/static/com/css/weui/weui.css"/>
    <link rel="stylesheet" href="/static/com/css/weui/weui2.css"/>
    <link rel="stylesheet" href="/static/mall/css/style.css">
    <{include file="public/header" /}>
</head>
<body ontouchstart style="background-color: #f8f8f8;">

<header class="wy-header">
    <div class="wy-header-icon-back"><span></span></div>
    <div class="wy-header-title">设置中心</div>
</header>


<div class="weui-panel">
    <div class="weui-panel__bd">
        <div class="weui-media-box weui-media-box_small-appmsg">
            <div class="weui-cells">
                <a class="weui-cell weui-cell_access" href="<{:url('msg')}>">
                    <div class="weui-cell__hd"><img src="/static/com/img/icon-msg-2.png" alt="" class="center-list-icon"></div>
                    <div class="weui-cell__bd weui-cell_primary">

                        <p class="center-list-txt">我的消息<span class="weui-badge msg-count" style="position: absolute;right: 28px;display: none"></span></p>
                    </div>
                    <span class="weui-cell__ft"></span>
                </a>
                <a class="weui-cell weui-cell_access" href="<{:url('record')}>">
                    <div class="weui-cell__hd"><img src="/static/mall/images/center-icon-jyjl.png" alt="" class="center-list-icon"></div>
                    <div class="weui-cell__bd weui-cell_primary">
                        <p class="center-list-txt">交易记录</p>
                    </div>
                    <span class="weui-cell__ft"></span>
                </a>
                <a class="weui-cell weui-cell_access" href="<{:url('/mall/goods/my_favorite')}>">
                    <div class="weui-cell__hd"><img src="/static/mall/images/center-icon-sc.png" alt="" class="center-list-icon"></div>
                    <div class="weui-cell__bd weui-cell_primary">
                        <p class="center-list-txt">我的收藏</p>
                    </div>
                    <span class="weui-cell__ft"></span>
                </a>
                <a class="weui-cell weui-cell_access" href="<{:url('/mall/user/address_list')}>">
                    <div class="weui-cell__hd"><img src="/static/mall/images/center-icon-dz.png" alt="" class="center-list-icon"></div>
                    <div class="weui-cell__bd weui-cell_primary">
                        <p class="center-list-txt">地址管理</p>
                    </div>
                    <span class="weui-cell__ft"></span>
                </a>

                <a class="weui-cell weui-cell_access" href="<{:url('/console/account/pwd_change')}>">
                    <div class="weui-cell__hd"><img src="/static/mall/images/center-icon-dlmm.png" alt="" class="center-list-icon"></div>
                    <div class="weui-cell__bd weui-cell_primary">
                        <p class="center-list-txt">登录密码修改</p>
                    </div>
                    <span class="weui-cell__ft"></span>
                </a>
                <a class="weui-cell weui-cell_access" href="<{:url('/console/account/pwd_change_pay')}>">
                    <div class="weui-cell__hd"><img src="/static/mall/images/center-icon-dlmm.png" alt="" class="center-list-icon"></div>
                    <div class="weui-cell__bd weui-cell_primary">
                        <p class="center-list-txt">支付密码修改</p>
                    </div>
                    <span class="weui-cell__ft"></span>
                </a>

            </div>
        </div>
    </div>
</div>


<section class="weui-menu">
    <div class="weui-menu-inner">
        <em></em>
        <span >工具</span>
        <ul class="nav-base-ul">
            <em></em>
            <li><a href="<{:url('/mall/user/feedback')}>?from=msg">留言</a></li>
            <li><a href="<{:url('/mall/user/feedback')}>?from=feedback">反馈</a></li>
        </ul>
    </div>
    <div class="weui-menu-inner">
        <em></em>
        <span>账户</span>
        <ul class="nav-base-ul">
            <em></em>
            <li onclick="bindwx()" class="bind_wx">绑定微信</li>
            <li onclick="logout()">退出登录</li>
        </ul>
    </div>
    <div class="weui-menu-inner">
        <em></em>
        <span>站点地图</span>
        <ul class="nav-base-ul">
            <em></em>
            <li><a href="<{:url('/mall/home/index')}>">首页</a></li>
            <li><a href="<{:url('/mall/user/index')}>">个人中心</a></li>
            <li><a href="<{:url('/mall/order/all_orders')}>">订单中心</a></li>
        </ul>
    </div>


</section>
<{include file="public/footer" /}>
<!--<script src="/static/mall/lib/zepto.js"></script>-->
<script>
    //const vConsole = new VConsole();
    $(function () {
        code = bs_get_param('code');
        openid = bs_get_param('openid');
        bs_request("<{:url('/mall/user/info')}>", {}, function (res) {
            if (res.code==0){
                if (res.data.user_info.openid_wx){
                    $(".bind_wx").text('解绑微信');
                    $(".bind_wx").data('action','unbind');
                }else {
                    $(".bind_wx").text('绑定微信');
                    $(".bind_wx").data('action','bind');
                }
            }
        });
        if (code||openid){
            dobind({code:code,openid:openid})
        }
    })
    function logout(){
          $.confirm('确定要退出吗',function () {
              localStorage.removeItem('user_token');
              location.href  = "<{:url('/console/account/logout')}>";
         })
    }
    function dobind(data) {
        bs_request("<{:url('/console/account/wx_bind')}>", data, function (res) {
            if (res.code==0){
                if (res.data.from=='code'){
                    $.toast(res.msg,'ok',function () {
                        location.href = res.data.url
                    })
                }else {
                    $.toast('绑定成功','success',function () {
                        location.href = "<{:url('setting')}>"
                    })
                }
            }else {
                $.alert(res.msg)
            }
        })
    }
    function bindwx(){
        var type = $(".bind_wx").data('action')
        if (type=='unbind'){
            $.confirm('确定要解绑微信吗？',function () {
                bs_request("<{:url('/console/account/wx_unbind')}>", {}, function (res) {
                    if (res.code==0){
                        location.reload();
                    }else {
                        $.alert(res.msg)
                    }
                })
            })
        }else {
            dobind({})
        }
    }

</script>
<script>

    $(function(){
        $('.weui-menu-inner').click(function () {
            var $menu = $(this).find('ul'),
                height = $menu.find('li').length * 40 + 15 ,
                opacity = $menu.css('opacity');

            $('.weui-menu-inner ul').css({
                'top': '50px',
                'opacity': '0'
            });

            if(opacity == 0) {
                $menu.css({
                    'top': '-' + height+'px',
                    'opacity': 1
                });
            }else {
                $menu.css({
                    'top': '50px',
                    'opacity': 0
                });
            }
        });
        //默认初始化给一个相对高度，防止触发第一个li
        $('.nav-base-ul').css({
            'top':'50px'
        })
        $(".wy-header-icon-back").on('click',function () {
            history.back();
        });
    });

</script>

</body>
</html>
